//
//  DINGRefreshControl.swift
//  0730Microblog
//
//  Created by ding on 15/8/12.
//  Copyright © 2015年 ding. All rights reserved.
//

import UIKit

class DINGRefreshControl: UIRefreshControl {
    
    override init() {
        super.init()
        
//        beginRefreshing()
        setUpUI()
    }
    
    private func setUpUI() {
        insertSubview(refreshView, belowSubview: <#T##UIView#>)
        refreshView.translatesAutoresizingMaskIntoConstraints = false
        addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[targetView]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["targetView" : refreshView]))
        addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[targetView]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["targetView" : refreshView]))
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func beginRefreshing() {
        super.beginRefreshing()
        
        print("kaishi菊花-----")
    }
    
    override func endRefreshing() {
        super.endRefreshing()
        
        print("jieshu菊花-----")
    }
    
    private lazy var refreshView: UIView = {
       let rView = UIView()
        rView.backgroundColor = UIColor.purpleColor()
        return rView
    }()

}
